package systemtest;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import name.fowler.refactoring.simplestore.domain.Movie;
import name.fowler.refactoring.simplestore.domain.PriceCodes;
import name.fowler.refactoring.simplestore.domain.Rental;

public class RentalBuilder {
	private Rental mockRental;
	
	public RentalBuilder withMovie(PriceCodes code) {
		Movie stubMovie = mock(Movie.class);
		when(stubMovie.getPriceCode()).thenReturn(code);
		
		if (mockRental == null) {
			mockRental = mock(Rental.class); 
		}
		
		when(mockRental.getMovie()).thenReturn(stubMovie);

		return this;
	}
	
	public RentalBuilder withDaysRented(int daysRented) {
		if (mockRental == null) {
			mockRental = mock(Rental.class); 
		}
		when(mockRental.getDaysRented()).thenReturn(daysRented);
		
		return this;
	}
	
	public Rental build() {
		return mockRental;
	}
	
	
}
